﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Arc.DairyMan.DairyMan.DataAccess;
using Arc.DairyMan.DairyMan.Model;
using Arc.WinForms.Controls;

namespace Arc.DairyMan.DairyMan.BusinessLogic
{
    public class blSettings : AbsBl
    {
        public blSettings(AbsBl ParentBl = null)
            : base(ParentBl)
        {
            ModelObj = new Settings();
            Dal = new dalSettings();
            Dal.ModelObj = ModelObj;
        }

        public override void Validation()
        {
            Settings _Model = (Settings)ModelObj;
        }

        public override void Search(string Critiera)
        {
            try
            {
                Dal.Search(Critiera, DS);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public override void Select(string Critiera)
        {
            try
            {
                Dal.Select(Critiera, DS);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public override int Transaction(bool TransactionStarter)
        {
            try
            {
                Result = 0;
                Dal.BeginTransaction(TransactionStarter);
                if (ModelObj.TransactionMode == Common.TransactionModes.Delete)
                {
                    //ClassList = new ArrayList();
                    //ClassList.Add("contact_license");
                    //clsConnection.FindData(_ModelObj.Database, _ModelObj.FriendlyName, "Contact_ID", _ModelObj.Contact_ID.ToString(), ClassList);
                }
                else
                {
                    Validation();
                    if (ModelObj.TransactionMode == Common.TransactionModes.Insert || ModelObj.TransactionMode == Common.TransactionModes.Update)
                    {
                        //Hashtable _ht = new Hashtable();
                        //_ht.Add("Contact_Name", _ModelObj.Contact_Name);
                        //_ht.Add("Contact_Alias", _ModelObj.Contact_Alias);
                        //clsConnection.CheckUnique(_ModelObj, "Contact_ID", _ht);
                    }
                }

                Dal.ModelObj = ModelObj;
                Result = Dal.Transaction();

                #region  Child Tran
                #endregion
                Dal.CommitTransaction(TransactionStarter);
                return Result;
            }
            catch (Exception ex)
            {
                Dal.RollbackTransaction(TransactionStarter);
                throw ex;
            }
        }
    }
}
